<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.aolong.archives.common.resource.ParameterUtil"%>
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://aolongroup.com/al-taglib" prefix="al"%>  
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<%
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	%>
	<base href="<%= basePath %>">
	<link rel="stylesheet" type="text/css" href="resources/css/login.css" />
	<script type="text/javascript" src="json/json.js"></script> 
	<script type="text/javascript" src="scripts/cookieUtilNew.js"></script> 
	<script type="text/javascript" src="scripts/md5.js" charset="utf-8"></script>
	<script type="text/javascript" src="scripts/md5-legacy.js" charset="utf-8"></script>
		
	<%
		Object oLanguage = request.getSession().getAttribute("SYS_LANGUAGE");
		
		String seesionLanguage = (oLanguage==null) ? "" : oLanguage.toString();
		System.out.println("seesionLanguage="+seesionLanguage);
	%>
	
	<script type="text/javascript">
		var xmlhttp;
		function getLanguageRedio()
		{
			var rObj = document.forms.userform.languageRedio;
			for(i=0;i<rObj.length;i++)
			{
				if (rObj[i].checked)
				{
					return rObj[i].value;	
				}
			}
		}
		function createXMLHttpRequest()
		{
			if (window.ActiveXObject)
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			else
			{
				xmlhttp = new XMLHttpRequest();
			}
		}
		function startRequest()
		{
			var name = document.getElementById("loginname").value;
			var pass = document.getElementById("password").value;
			
			var lang = getLanguageRedio();
			var url="sm/login.action?loginname="+name+"&password="+hex_md5(pass)+"&language="+lang;
			createXMLHttpRequest();
			xmlhttp.onreadystatechange=stateChange;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}
		function stateChange()
		{
			if (xmlhttp.readyState==4)
			{
				if (xmlhttp.status==200)
				{
					if (xmlhttp.responseText != "")
					{
						var result = JSON.parse(xmlhttp.responseText);
						if (result.success)
						{
							var lang = getLanguageRedio();
							setCookie('language',lang);
							setCookie('loginname',document.getElementById("loginname").value);
							location.href = "<%= basePath %>sm/welcome.action";
						}
						else
						{
							document.getElementById("errmsg").innerHTML = result.errDesc;
						}
					}
				}
			}
		}
	</script>
	<script type="text/javascript">
		function getLoginInfo()
		{
			document.getElementById("loginname").value = getCookie('loginname');
			var language = '<%=seesionLanguage%>';
			if (language == null || language.length == 0) language = getCookie('language');
			if (language == null || language.length == 0) language = '<%=ParameterUtil.getParameter("language")%>';
			var rObj = document.forms.userform.languageRedio;
			for(i=0;i<rObj.length;i++)
			{
				if (rObj[i].value == language)
				{
					rObj[i].checked=true;	
				}
			}	
		}
		function checkLanguage(language) {
			
			document.forms.userform.action="languageSwitcherServlet";
            document.forms.userform.submit();
		}
	</script>
	<title><al:resource key="System - Login" /></title>
</head>
<body onLoad="getLoginInfo()">
	<!--form method="post" action="archives/login.action" name="userForm" id="userform">
		<input name="userId" type="text"/>
		<input name="password" type="password"/>
		<input type="radio" name="languageid" value="zh_CN" /> 中文
		<input type="radio" name="languageid" value="zh_CN" /> English
		<input id="btn_submit" type="submit" title="立即登录" />
		<input id="btn_reset"  type="reset" title="重置" />
	</form-->
	<script type="text/javascript">
	</script>
    <div class="wrapper">
        <div class="header">
            <div class="logo"><img src="resources/images/login/logo_login.png" /></div>
        </div>
        <div class="main">
            <div class="banner">
              <div class="banner_pic"></div>
            </div>
            <div class="loginbox">
                <div class="out">
                    <div class="title"><h2><img src="resources/images/login/logo_pass.jpg" /></h2></div>
                    <div class="center">
	                    <form method="get" action=""  name="userForm" id="userform">
	                        <span id="tip" class="tip">&nbsp;</span>
	                        <span id="tip2" style="display:none;" class="tip">&nbsp;</span>
		                    <ul>
		                        <li>
		                          <em><al:resource key="LoginName" />&nbsp;:&nbsp;&nbsp;</em>
		                          <span class="s1">
		                              <input name="loginname" type="text" maxlength="50" id="loginname"
		                                  autocomplete="off"  size="20" />
		                                  <!-- onFocus="fEvent('focus',this)" 
		                                  onBlur="fEvent('blur',this)" 
		                                  onMouseOver="fEvent('mouseover',this)" 
		                                  onMouseOut="fEvent('mouseout',this)" class="inp"  -->
		                          </span>
		                        </li>
		                        <li>
		                          <em><al:resource key="Password" />&nbsp;:&nbsp;&nbsp;</em>
		                          <span class="s1"> 
		                              <input id="password" name="password" type="password" 
		                              maxlength="20"  size="20" /> 
		                              <!--onFocus="fEvent('focus',this)" 
		                              onBlur="fEvent('blur',this)" 
		                              onMouseOver="fEvent('mouseover',this)" 
		                              onMouseOut="fEvent('mouseout',this)" class="inp" -->
		                          </span>
		                        </li>
		                        <li>
		                        	<span class="s2"></span>
		                            <label>
		                                <input type="radio" onclick="checkLanguage('zh_CN')" name ="languageRedio" value="zh_CN"  /> 中文
		                                <input type="radio" onclick="checkLanguage('en_US')" name ="languageRedio" value="en_US"  /> English
		                            </label>
		                        </li>
		                    </ul>
		                    <div style="float:center; color:red;" id="errmsg" ></div>
		                    <div class="login_btnok"> 
		                        <input class="button1" id="btn_submit" type="button" value="" onclick="startRequest();return false;" title="立即登录"/>   
		                        <input class="button2" id="btn_reset" type="button" value=""  title="重置"/>
		                    </div>
	                    </form>
                    </div>
                    <div class="bottom">
                		<jsp:useBean id="now" class="java.util.Date"></jsp:useBean> 
      				</div>
                </div>
            </div>
        </div>
        <div class="footer">
            <p> Copyright © 2003 - 
            	<script LANGUAGE="JavaScript">
		            year=(new Date()).getYear();
					year=(year > 200) ? year : 1900 + year;
					document.write(year); 
				</script>&nbsp;<al:resource key="System - Name" /></p>
        </div>
    </div>
</body>
</html>